import { defineStore } from 'pinia'
import { createOrder } from '@/api/index'
// import { showToast } from '@tarojs/taro'
// import { switchTab } from '@/router'

export const useOrderStore = defineStore('order', {
  state: () => ({
    activityInfo: null,
    taskInfo: null,
    activetab: 0, // 当前激活的任务tab
  }),
  actions: {
    setCreateBeforeAct(actInfo){
        this.activityInfo = actInfo
    },
    setTaskInfo(task){
      this.taskInfo = task
    },
    setActiveTab(id){
      this.activetab = id
    },
    async CreatApplyOrder(parame){
      try {
        const data = {type: 1, ...parame}
        const res = await createOrder(data)
        return res.data ? res.data: false
      } catch (error) {
        throw error
      }
    },
  }
})

export default useOrderStore